﻿/**
 * -------------------------------MD5加密器-------------------------
 * 时间:2018/11/08
 * 作者:范德澄
 * 邮件:457343315@1qq.com
 * 描述：这是MD5加密器窗体
 */
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MD5EncryptionDevice
{
    public partial class MD5Encryption : Form
    {
        public MD5Encryption()
        {
            InitializeComponent();
            comboBox1.SelectedIndex = 0;
            comboBox2.SelectedIndex = 0;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != "")
            {
                int i = Convert.ToInt32(textBox1.Text);
                string str = MD5Arithmetic.Int2String(i);
                this.textBox1.Text = str;
            }
            else
            {
                MessageBox.Show("请输入数字");
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox2.Text != "")
            {
                string i = textBox2.Text;
                string str = MD5Arithmetic.String2String(i);
                this.textBox2.Text = str;
            }
            else
            {
                MessageBox.Show("请输入字符串");
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            if (textBox3.Text != "")
            {
                string dp = comboBox1.Text;
                switch (dp)
                {

                    case "Ulong": textBox3.Text = MD5Arithmetic.String2Ulong(textBox3.Text).ToString(); break;
                    case "String": textBox3.Text = MD5Arithmetic.String2String(textBox3.Text); break;
                }
            }
            else
            {
                MessageBox.Show("请输入字符串");
            }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            if (textBox4.Text != "")
            {
                string dp = comboBox2.Text;
                string[] str = dp.Split('~');
                textBox4.Text = MD5Arithmetic.String2Int(textBox4.Text, Convert.ToInt32(str[0]), Convert.ToInt32(str[1])).ToString();
            }
            else
            {
                MessageBox.Show("请输入字符串");
            }
        }
    }
}
